﻿var preMenu = null;
var preLeftMenu = null;


function showmenudymaic(id, src) {
    $ = jQuery.noConflict();
    if ($("[id$='divLeftMenu']").length > 0) {
        var dom = $("[id$='divLeftMenu']").find("*");
        for (i = 0; i < dom.length; i++) {
            if (dom[i].id.substr(0, 2) == "ul") {
                dom[i].style.display = "none";
            }
        }
        var o = $("#ul" + id);
        if (o.length > 0) {

            o[0].style.display = "";
            if (preLeftMenu != null) {
                preLeftMenu.className = "";
            }

            var leftid = src.replace("/", "").replace(".aspx", "").replace("?", "").replace("=", "");
            if ($("#menu" + leftid).length > 0) {
                $("#menu" + leftid)[0].className = "CurrentTab";
                preLeftMenu = $("#menu" + leftid)[0];
            }
        }

        if (preMenu != null) {
            preMenu.className = "";
        }
        $('#menu' + id)[0].className = "CurrentTab1";
        $("#ah" + id).addClass("current").siblings("a").removeClass("current");
        preMenu = $('#menu' + id)[0];
        var ifr = $("#frm")[0];
        ifr.src = src;
    }
    else {

        window.location = "default.aspx?menu=" + id;

    }
}


function showTopmenu(id, src) {
    $ = jQuery.noConflict();
    var ifr = $("#frm")[0];
    $("#ah" + id).addClass("on").siblings("a").removeClass("on");
    ifr.src = src;
}

function ChangeTopmenu(id, src) {
    $ = jQuery.noConflict();
    var ifr = window.parent.$("#frm")[0];
    window.parent.$("#ah" + id).addClass("on").siblings("a").removeClass("on");
    ifr.src = src;
}

function seftleftmenu(src) {
    $ = jQuery.noConflict();
    if (preLeftMenu != null) {
        preLeftMenu.className = "";
    }


    var leftid = src.replace("/", "").replace(".aspx", "").replace("/", "").replace("&", "").replace("?", "").replace("=", "");
    if ($("#menu" + leftid).length > 0) {
        $("#menu" + leftid)[0].className = "CurrentTab";
        preLeftMenu = $("#menu" + leftid)[0];
    }
}

function seftleftmenu22(menuid) {
    $("#" + menuid).addClass("on").siblings().removeClass("on");
    //    $ = jQuery.noConflict();
    //    if (preLeftMenu != null) {
    //        preLeftMenu.className = "";
    //    }

    //    if ($("#" + menuid).length > 0) {
    //        $("#" + menuid)[0].className = "CurrentTab";
    //        preLeftMenu = $("#" + menuid)[0];
    //    }
}

function resize() {
    $ = jQuery.noConflict();
    //var nHeight = frm.document.body.clientHeight;
    var nHeight = 0;
    if (frm.document) {
        nHeight = frm.document.body.clientHeight;
    }
    else {
        nHeight = frm.contentDocument.body.clientHeight;
    }
    //alert(nHeight);

    if (nHeight > 410) {
        $('#frm')[0].style.height = (nHeight + 10) + 'px';
        $('#divFrm')[0].style.height = (nHeight + 20) + 'px';

    }
    else {
        $('#frm')[0].style.height = '410px';
        $('#divFrm')[0].style.height = '420px';
    }

}




/**********************************************************/
function popWindow() {
    var win = window.open("Default.aspx?menu=" + MenuId + "&openurl=(" + currPopMenuHref + ")");
}

function popWindowTop() {
    if (MenuId == '001') {
        var win = window.open("MainPage.aspx");
    }
    else {
        var win = window.open("Default.aspx?menu=" + MenuId + "&type=1");
    }
}

function GetLinkData(divshow, linktypeid) {
    $.ajax({
        type: "get",
        url: "../UserControl/SuggestBox/GetLinkData.ashx",
        cache: false,
        data: {
            id: linktypeid
        },
        success: function (data, textStatus) {
            divshow.html(data);
        },
        complete: function (XMLHttpRequest, textStatus) {
            //HideLoading();
        },
        error: function () {
            //请求出错处理
        }
    });
}

function easytabs(menunr, active) {
    if (active == "2") {
        active = "MD01";
    }
    if (menunr == autochangemenu)
    { currenttab = active; }
    if ((menunr == autochangemenu) && (stoponhover == 1))
    { stop_autochange() }
    else if ((menunr == autochangemenu) && (stoponhover == 0))
    { counter = 0; }
    menunr = menunr - 1;
    var smenuid = "MD01,SYS01,OM01,BOM01,PL01,ST01,KF01,PS01,OUT01";
    var strs = smenuid.split(",");
    for (i = 0; i < strs.length; i++) {
        if (document.getElementById(tablink_idname[menunr] + strs[i])) {
            document.getElementById(tablink_idname[menunr] + strs[i]).className = '';
        }
        if (document.getElementById(tabcontent_idname[menunr] + strs[i])) {
            document.getElementById(tabcontent_idname[menunr] + strs[i]).style.display = 'none';
        }

    }
    document.getElementById(tabcontent_idname[menunr] + active).style.display = 'block';
}

function showFirstTopmenu(id, src) {
    $ = jQuery.noConflict();
    var ifr = $("#frm")[0];
    ifr.src = src;
}